#!/usr/bin/env python
#-*- coding: utf-8 -*-
#__author__:vincentlc
#time: 16/4/2 : 23:41
'''
Given a column title as appear in an Excel sheet, return its corresponding column number.

For example:

    A -> 1
    B -> 2
    C -> 3
    ...
    Z -> 26
    AA -> 27
    AB -> 28
'''

class Solution(object):
    def titleToNumber(self, s):
        """
        :type s: str
        :rtype: int
        """
        sum = 0
        j = 0
        if s != None:
            s = s.upper()
            for i in s[::-1]:
                sum += (ord(i)-64)*(26**j)
                j+=1

            return sum

a = Solution()
print (a.titleToNumber('AA'))
print (a.titleToNumber('AB'))
print (a.titleToNumber('Ao'))



